# -*- coding: utf-8 -*-

#The prime factors of 13195 are 5, 7, 13 and 29.
#What is the largest prime factor of the number 600851475143 ?

from math import *
from math_ext import *


def prob3(n):
    top = int(sqrt(n))
    
    array = []
    for i in range(2, top + 1):
        if is_prime(i):
            pair = divmod(n, i)
            if pair[1] == 0:
                print i
                array.append(i)
    array.sort()
    return array[len(array) - 1]

n = 600851475143
m = 13195 
print prob3(n)